/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8fafb;
    color: #1a202c;
    line-height: 1.6;
    min-height: 100vh;
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
//    padding: 40px 0;
padding: 10px 0;

    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.header-content h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a202c;
}

.header-content p {
    font-size: 15px;
    color: #718096;
    font-weight: 400;
}

.header-content i {
    margin-right: 8px;
    color: #4299e1;
}

/* Calculator Wrapper */
.calculator-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 10px;
    margin-bottom: 30px;
}

/* Panel Styles */
.input-panel,
.results-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
}

.panel-header {
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
  //  padding: 20px 24px;
padding: 2px 6px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    color: #2d3748;
}

.panel-header i {
    margin-right: 8px;
    font-size: 16px;
    color: #4299e1;
}

/* Input Styles */
.input-group {
//    padding: 16px 24px;
  padding: 4px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.input-group:last-child {
    border-bottom: none;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #4a5568;
    font-size: 13px;
}

label i {
    margin-right: 6px;
    color: #4299e1;
    width: 14px;
    text-align: center;
}

.form-control {
    width: 100%;
   // padding: 10px 12px;
padding: 3px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Currency Input */
.currency-input {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 9px;
    z-index: 1;
    font-weight: 600;
    color: #6b7280;
    font-size: 1rem;
}

.currency-input .form-control {
    padding-left: 40px;
}

/* Input Row */
.input-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.input-row .form-control {
    flex: 1;
}

.percentage-display {
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 500;
    color: #6366f1;
    min-width: 60px;
    text-align: center;
}

.unit {
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

/* Sliders */
.down-payment-slider,
.loan-term-slider {
//    margin-top: 15px;
margin-top: -5px;
}

.down-payment-slider input[type="range"],
.loan-term-slider input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

.down-payment-slider input[type="range"]::-webkit-slider-thumb,
.loan-term-slider input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    // margin-top: 15px;
margin-top: -5px;
    font-size: 0.85rem;
    color: #6b7280;
}

/* Country Info */
.country-info {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f0f9ff;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #0369a1;
    border-left: 4px solid #0ea5e9;
    display: none;
}

.rate-info {
    margin-top: 10px;
//    padding: 10px 14px;
 padding: 4px 8px;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #92400e;
    display: none;
}

/* Collapsible Sections */
.collapsible-section {
    border-bottom: 1px solid #f1f5f9;
}

.section-toggle {
    width: 100%;
 //   padding: 20px 30px;
padding: 10px 20px;
    background: none;
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.section-toggle:hover {
    background: #f9fafb;
}

.section-toggle i {
    margin-right: 10px;
    transition: transform 0.3s ease;
}

.section-toggle.active i {
    transform: rotate(45deg);
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.section-content.active {
    max-height: 1000px;
}

/* Calculate Button */
.calculate-btn {
    width: calc(100% - 48px);
    padding: 12px 20px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
   // margin: 16px 24px 24px 24px;
  margin: 4px 4px 24px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculate-btn:hover {
    background: #3182ce;
}

.calculate-btn i {
    margin-right: 6px;
}

/* Results Panel */
.results-panel {
    padding-bottom: 20px;
}

/* Main Payment Display */
.main-payment-display {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.payment-amount {
    display: inline-block;
}

.payment-label {
    font-size: 14px;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 500;
}

.payment-value {
    font-size: 32px;
    font-weight: 700;
    color: #2d3748;
    line-height: 1;
}

/* Key Numbers Grid */
.key-numbers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e2e8f0;
    margin: 0;
}

.number-card {
    background: white;
    padding: 16px;
    text-align: center;
}

.number-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 500;
}

.number-value {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

/* Chart Sections */
.chart-section {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
}

.chart-section:last-child {
    border-bottom: none;
}

.chart-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
}

.chart-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.chart-wrapper canvas {
    max-width: 100%;
    height: auto;
}

/* Breakdown Legend */
.breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Additional Costs */
.additional-costs {
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
}

.additional-costs h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
}

.cost-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-label {
    font-size: 13px;
    color: #4a5568;
    font-weight: 500;
}

.cost-value {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

/* Loan Summary */
.loan-summary {
    padding: 0 30px 20px 30px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row .label {
    font-weight: 500;
    color: #64748b;
}

.summary-row .value {
    font-weight: 600;
    color: #1e293b;
    font-size: 1.1rem;
}

/* Payment Chart */
.chart-container {
    padding: 20px 30px 30px 30px;
}

.chart-container h3 {
    margin-bottom: 20px;
    color: #1e293b;
    font-weight: 600;
}

.payment-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-segment {
    display: flex;
    align-items: center;
    gap: 15px;
}

.segment-bar {
    height: 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: 0;
    flex: 1;
    max-width: 200px;
}

.segment-label {
    font-size: 0.9rem;
    color: #64748b;
    min-width: 120px;
    font-weight: 500;
}

.segment-value {
    font-weight: 600;
    color: #1e293b;
    min-width: 80px;
    text-align: right;
}

/* Chart Colors */
#principalSegment .segment-bar { background: #6366f1; }
#taxSegment .segment-bar { background: #f59e0b; }
#insuranceSegment .segment-bar { background: #10b981; }
#pmiSegment .segment-bar { background: #ef4444; }
#hoaSegment .segment-bar { background: #8b5cf6; }

/* Amortization Section */
.amortization-section {
    padding: 20px 30px 30px 30px;
    border-top: 1px solid #f1f5f9;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    color: #1e293b;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.section-header h3 i {
    margin-right: 10px;
    color: #6366f1;
}

.schedule-controls {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-small:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-small.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

/* Table */
.table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.amortization-table thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.amortization-table th,
.amortization-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.amortization-table th {
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.amortization-table tbody tr:hover {
    background: #f8fafc;
}

.amortization-table td {
    color: #1e293b;
}

.amortization-table td:nth-child(n+3) {
    text-align: right;
}

/* Comparison Section */
.comparison-section {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 40px;
    overflow: hidden;
}

.comparison-grid {
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.loading-spinner i {
    font-size: 2rem;
    color: #6366f1;
    margin-bottom: 15px;
}

.loading-spinner p {
    color: #64748b;
    font-weight: 500;
}

/* Footer */
.footer {
    text-align: center;
    color: white;
    padding: 30px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-content p {
    margin-bottom: 10px;
    opacity: 0.9;
}

.footer-links {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.loading-spinner i {
    font-size: 24px;
    color: #4299e1;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #4a5568;
    font-weight: 500;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calculator-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .input-panel {
        order: 1;
    }
    
    .results-panel {
        order: 2;
    }
    
    .header-content h1 {
        font-size: 24px;
    }
    
    .key-numbers {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .input-group {
        padding: 15px 20px;
    }
    
    .panel-header {
        padding: 20px;
    }
    
    .payment-summary,
    .loan-summary,
    .chart-container,
    .amortization-section {
        padding: 15px 20px;
    }
    
    .calculate-btn {
        margin: 15px 20px 20px 20px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .input-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .schedule-controls {
        width: 100%;
        justify-content: center;
    }
    
    .chart-segment {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .segment-bar {
        width: 100%;
        max-width: none;
    }
    
    .amortization-table {
        font-size: 0.8rem;
    }
    
    .amortization-table th,
    .amortization-table td {
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .summary-card.primary .card-value {
        font-size: 1.8rem;
    }
    
    .input-group {
        padding: 12px 15px;
    }
    
    .panel-header {
        padding: 15px;
    }
    
    .payment-summary,
    .loan-summary,
    .chart-container,
    .amortization-section {
        padding: 12px 15px;
    }
    
    .calculate-btn {
        margin: 12px 15px 15px 15px;
        padding: 15px 20px;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}



/* === Improved Responsive Layout === */
@media (max-width: 768px) {
    .calculator-wrapper {
        display: flex;
        flex-direction: column;
    }

    .input-panel,
    .results-panel {
        width: 100%;
    }

    .input-row {
        flex-direction: column;
        gap: 8px;
    }

    .currency-input {
        width: 100%;
    }

    .percentage-display,
    .unit {
        align-self: flex-start;
    }

    .key-numbers {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.2rem;
    }

    .calculate-btn {
        width: 100%;
        margin: 15px 0;
    }

    .chart-wrapper canvas {
        width: 100% !important;
        height: auto !important;
    }

    .amortization-table th,
    .amortization-table td {
        font-size: 0.7rem;
        padding: 6px;
    }
}
